package fr.mywiki.model.jdbcAdapter.values;

import java.util.Collection;

import fr.mywiki.model.ejbAdapter.Value;


public class UserValue extends AbstractValueObject{
	private static final long serialVersionUID = 1L;
	/* The fields of the database */
	/** Contains the identifier of the user. Is also the primary key of the table */
	public static final String ID = "id";
	/** Contains the login of the user. */
	public static final String LOGIN = "login";
	/**
	 * Contains the password of this user. The couple (login,password) enables the connection to the
	 * system
	 */ 
	public static final String PASSWORD = "password";
	
	/**
	 * The type of object represented by an instance of this class.
	 */
	public static final String TYPE = "user";
	
	/**
	 * The different fields of that kind of object.
	 */
	public static final String[] FIELD_NAMES = { ID, LOGIN, PASSWORD };
	
	public static final String IDENTIFIER = ID;
	
	private Long id;
	private String login;
	private String password;
	
	public String getTypeEnt() {
		return TYPE_ENT;
	}
	
	public Object get(String attName) {
		if (ID.equals(attName))
			return getId();
		if (LOGIN.equals(attName))
			return getLogin();
		if(PASSWORD.equals(attName))
			return getPassword();
		return null;
	}
	
	public void set(String attName,Object value) {
		if (ID.equals(attName))
			setId((Long)value);
		if (LOGIN.equals(attName))
			setLogin((String)value);
		if(PASSWORD.equals(attName))
			setPassword((String)value);
	}

	public String getType() {
		return TYPE;
	}

	public String getIdentifierFieldName() {
		return IDENTIFIER;
	}
	
	public String[] getFieldNames() {
		return FIELD_NAMES;
	}
	
	public Object getIdentifier() {
		return get(IDENTIFIER);
	}
	
	/* Getters/setters */
	
	public String getLogin() { return login; }
	public void setLogin(String login) { this.login = login;	}
	public String getPassword() { return password; }
	public void setPassword(String password) { this.password = password; }
	public Long getId() { return id; }
	public void setId(Long id) {	this.id = id; }

	public Collection getLinks(String relName) {
		return null;
	}

	public void addLink(String relName, Value added) {
	}

	public void addLinks(String relName, Collection added) {
	}

	public boolean isLinked(String relName, Value linked) {
		return false;
	}

	public void removeLink(String relName, Value removed) {
	}

	public void removeAllLinks(String relName) {
	}
}
